<?php
global $title;
$title = array(
			'综合',
			'技术',
			'二次创作',
			'动画漫画', 
			'值班室',  
			'游戏',     
			'欢乐恶搞',   
			'小说',     
			'数码音乐',   
			'射影',     
			'都市怪谈',   
			'支援1' 
			
		);
function week($timeStamp){
	$posttime_year=0;$posttime_month=0;$posttime_day=0;
	sscanf($timeStamp,"%d-%d-%d",$posttime_year,$posttime_month,$posttime_day);
	//echo $posttime_year,$posttime_month,$posttime_day;
	$weekday = idate("w",mktime(0,0,0,$posttime_month,$posttime_day,$posttime_year));
	$arr = array("日","一","二","三","四","五","六");
	return $arr[$weekday];
}
function debug_p($ds){
	echo '<p>'.$ds.'</p>';
}
function get_GETInt($s,$errorInit=0){
	if(isset($_GET[$s]) && filter_var($_GET[$s],FILTER_VALIDATE_INT)){
		return $_GET[$s];	
	}
	return 0;
}
function get_POSTInt($s,$errorInit=0){
	if(isset($_POST[$s]) && filter_var($_POST[$s],FILTER_VALIDATE_INT)){
		return $_POST[$s];	
	}
	return $errorInit;
}
function turnTo404(){
	echo '<meta http-equiv="Refresh" content="0;url=../404.html">';	
}

function saveUploadFile($fileName){//用英文代替中文编码
//	$fileName = mysql_escape_string($fileName);
	if ((
	       ($_FILES[$fileName]["type"] == "image/gif")
		|| ($_FILES[$fileName]["type"] == "image/jpeg")
		|| ($_FILES[$fileName]["type"] == "image/pjpeg")
		|| ($_FILES[$fileName]["type"] == "image/png")
		|| ($_FILES[$fileName]["type"] == "image/bmp")
		)
	&& ($_FILES[$fileName]["size"] < 2000000)){
		if ($_FILES[$fileName]["error"] > 0){
			echo "Return Code: " . $_FILES[$fileName]["error"] . "<br />";
			return NULL;
		}
		else{
			echo "Upload: " . $_FILES[$fileName]["name"] . "<br />";
			echo "Type: " . $_FILES[$fileName]["type"] . "<br />";
			echo "Size: " . ($_FILES[$fileName]["size"] / 1024) . " Kb<br />";
			echo "Temp file: " . $_FILES[$fileName]["tmp_name"] . "<br />";
			$upDir = "../uploadPic/";
			$fN = urlencode($_FILES[$fileName]["name"]);
			$fN = str_ireplace('%','r',$fN);
			if (file_exists($upDir.$fN)){
				echo $fN . " already exists. ";

			}
			else{
				move_uploaded_file($_FILES[$fileName]["tmp_name"],
				$upDir.$fN);
				echo "Stored in: ".$upDir.$fN;
			}
			return $upDir.$fN;
			
		}
	}
	else{
		//echo "pic invalid";
		return NULL;
	}	

}
function getRealUserId($ckuser){
	$stSalt = 4;
	return substr(base64_decode($ckuser),$stSalt);	
}

?>
